import {globalAdapter, IGlobalAdapter} from "../../adapterInterface/model1/IGlobalAdapter";
import {Logger} from "../../../config/Logger";
import {CodeUtil} from "../../../../codeAdapter/CodeUtil";

export enum ItemDataType {
    art = 1,
    tip ,
    ubertip1,
    name ,
    ubertip2,
}

export class GlobalAdapter implements IGlobalAdapter {

    setFog(value: boolean) {
        FogEnable(value);
    }

    setMask(value: boolean) {
        FogMaskEnable(value);
    }

    setSkyModel(value: string) {
        SetSkyModel(value);
    }

    setTimeOfDay(num: number) {
        SetTimeOfDay(num);
    }

    setTimeOfDayScale(num: number) {
        SetTimeOfDayScale(num);
    }

    setItemUbertip(itemId: string, tip: string) {
        EXSetItemDataString(itemId, ItemDataType.ubertip1, tip);
        EXSetItemDataString(itemId, ItemDataType.ubertip2, tip);
    }

    stopBackMusic(fadeOut: boolean) {
        StopMusicBJ(fadeOut);
    }

    startBackMusic(path: string) {
        // ClearMapMusicBJ();
        // SetMapMusicIndexedBJ(path, 1);
        PlayMusicBJ(path);
    }

    toast(text: string, playerId: number = -1) {
        if (CodeUtil.isNullOrZero(text)) {
            return false;
        }
        if (playerId >= 0) {
            DisplayTextToPlayer(Player(playerId), 0, 0, text);
            if (playerId === GetPlayerId(GetLocalPlayer())) {
                return true;
            }
            return false
        } else {
            DisplayTextToPlayer(GetLocalPlayer(), 0, 0, text);
            return true;
        }
    }

    getHandleId(handle: any) {
        if (handle) {
            const id = `${GetHandleId(handle)}`
            return id;
        }
    }

    getStartTime() {
        return DzAPI_Map_GetGameStartTime();
    }

    addItemToAllStock(itemId: string, num: number) {
        AddItemToAllStock(itemId, num, num);
    }

    removeItemFromAllStock(itemId: string) {
        RemoveItemFromAllStock(itemId);
    }

}